﻿<Page x:Class="WpfBinding.BasicBindings"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="BasicBindings" Height="300" Width="300">
    <Grid>
        <TextBlock Background="LightBlue" Width="140" Height="23" HorizontalAlignment="Left" Margin="12,83,0,0" Name="textBlock1" 
                   Text="{Binding Path=SelectedItem.Content,ElementName=comboBox1,StringFormat=Content:{0}}" VerticalAlignment="Top" />
        <ComboBox Height="23" HorizontalAlignment="Left" Margin="12,39,0,0" Name="comboBox1" VerticalAlignment="Top" Width="120" >
            <ComboBoxItem  Content="1111"/>
            <ComboBoxItem  Content="2222"/>
            <ComboBoxItem  Content="3333"/>
            <ComboBoxItem  Content="4444"/>
        </ComboBox>
        <TextBlock  Background="LightBlue" Height="23" HorizontalAlignment="Left" Margin="167,83,0,0" Name="textBlock2" Text="TextBlock"
                   VerticalAlignment="Top" Width="125" >
        </TextBlock>
        <TextBlock Background="LightBlue" Height="23" HorizontalAlignment="Left" Margin="323,83,0,0" Name="textBlock3" Text="TextBlock" VerticalAlignment="Top" Width="125" />
        <Button Content="Add Binding" Height="23" HorizontalAlignment="Left" Margin="52,6,0,0" Name="btnAdd" VerticalAlignment="Top" Width="75" Click="btnAdd_Click" />
        <Button Content="Remove Binding" Height="23" HorizontalAlignment="Left" Margin="167,6,0,0" Name="btnMove" VerticalAlignment="Top" Width="75" Click="btnMove_Click" />
        <StackPanel HorizontalAlignment="Left" Margin="12,141,0,0">
            <TextBlock Height="23"   Name="textBlock4" Text="{Binding RelativeSource={RelativeSource Mode=Self},Path=Name}" VerticalAlignment="Top" />
        </StackPanel>
        <TextBlock Text="{Binding RelativeSource={RelativeSource Mode=Self},Path=Width,StringFormat=宽度为{0}}" 
            Background="LightBlue" HorizontalAlignment="Left" Margin="109,154,0,0" Name="textBlock5" 
                   VerticalAlignment="Top" Width="125" />
    </Grid>
</Page>
